//
//  WelcomeViewController.m
//  SHShopping
//
//  Created by 坤鼎 on 2019/9/9.
//  Copyright © 2019 kunding. All rights reserved.
//

#import "WelcomeViewController.h"

@interface WelcomeViewController ()

@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _currentIndex = 0;
    
    UIScrollView *bgSV = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    bgSV.pagingEnabled = YES;
    bgSV.contentSize = CGSizeMake(SCREEN_WIDTH * 3, SCREEN_HEIGHT);
    bgSV.showsHorizontalScrollIndicator = YES;
    bgSV.delegate = self;
    [self.view addSubview:bgSV];
    
    for (int i = 0; i < 3; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, self.view.frame.size.width, SCREEN_HEIGHT)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"launch%d", i]];
        imageView.contentMode = UIViewContentModeScaleToFill;
        imageView.userInteractionEnabled = YES;
        [bgSV addSubview:imageView];
        
        UIButton *btnSkip = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 15 - 53, 15 + kNavBarAndStatusBarHeight - kNavBarHeight, 53, 28)];
        [btnSkip setTitle:@"跳过" forState:UIControlStateNormal];
        [btnSkip setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
        btnSkip.titleLabel.font = FONT(14);
        btnSkip.layer.borderColor = UIColorFromRGB(0x999999).CGColor;
        btnSkip.layer.borderWidth = 1;
        btnSkip.layer.cornerRadius = 14;
        btnSkip.layer.masksToBounds = YES;
        [btnSkip addTarget:self action:@selector(toHomeVC) forControlEvents:UIControlEventTouchUpInside];
        [imageView addSubview:btnSkip];
        
        
        UIImageView *imageViewIndex = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 44) / 2, SCREEN_HEIGHT - 45 - 6, 44, 6)];
        imageViewIndex.image = [UIImage imageNamed:[NSString stringWithFormat:@"launch_index%d", i]];
        [imageView addSubview:imageViewIndex];
        
        
        if (i == 2) {
            imageView.userInteractionEnabled = YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toHomeVC)];
            [imageView addGestureRecognizer:tap];
            
            UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 140) / 2, SCREEN_HEIGHT - 83 - 42, 140, 42)];
            [btn addTarget:self action:@selector(toHomeVC) forControlEvents:UIControlEventTouchUpInside];
            [btn setTitle:@"开启早安上海" forState:UIControlStateNormal];
            [btn gradientViewColorArray:@[] pointArr:@[]];
            
            [imageView addSubview:btn];
        }
    }
}

- (void)viewWillAppear:(BOOL)animated {
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated {
    self.navigationController.navigationBarHidden = NO;
}

- (void)toHomeVC {
    
    MainTabBarVC *vc = [[MainTabBarVC alloc] init];
    
    [UIApplication sharedApplication].keyWindow.rootViewController = vc;
}



@end
